package com.study.web.dao.syspermission.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.study.common.base.dao.BaseDaoImpl;
import com.study.common.exception.BizException;
import com.study.web.dao.syspermission.SysPermissionDao;
import com.study.web.dto.PermissionDto;
import com.study.web.entity.SysPermission;
import com.study.web.entity.SysRolePermission;

/**
 * SysPermissionDaoImpl.java
 * @author yaojinshan
 * @since 2018年6月11日下午5:01:53
 */
@Repository("sysPermissionDao")
public class SysPermissionDaoImpl extends BaseDaoImpl<SysPermission> implements SysPermissionDao {

	public List<Map<String,Object>> queryMenuDtoListByParentIdAndRoleId(Map<String,Object> paramsMap) throws BizException {
		List<Map<String,Object>> mapList = getSessionTemplate().selectList("queryMenuDtoListByParentIdAndRoleId",paramsMap);
		return mapList;
	}

	public List<SysPermission> queryFirstLevelMenuByRoleId(Map<String, Object> paramsMap) {
		return getSessionTemplate().selectList("queryFirstLevelMenuByRoleId",paramsMap);
	}

	public List<PermissionDto> queryPermisssonOfRole(Map<String, Object> allUseableRolePermisssonParamMap) {
		return  getSessionTemplate().selectList("queryPermisssonOfRole",allUseableRolePermisssonParamMap);
	}

	public void deleteOldRolePermission(Long roleId) {
		getSessionTemplate().delete("deleteOldRolePermission", roleId);
	}

	public void batchInsertRolePermission(List<SysRolePermission> list) {
		getSessionTemplate().insert("batchInsertRolePermission", list);
	}
}
